// pages/luck/components/luck-card/index.js
import {
  luckyInfo
} from '../../../../api/lucky/index'
import {
  fetchConstellationDate,
  fetchConstellationAvater
} from './config'
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    selectedConstellation: {
      type: String,
      require: true
    }
  },
  attached() {
    this.luckyInfo(this.data.selectedConstellation)
  },
  /**
   * 组件的初始数据
   */
  data: {
    name: "",
    nameDate: "",
    QFriend: "",
    color: "",
    datetime: "",
    health: "",
    love: "",
    work: "",
    money: "",
    number: 0,
    summary: "",
    all: "",
    avater: ""
  },

  /**
   * 组件的方法列表
   */
  methods: {
    luckyInfo(selectedConstellation) {
      luckyInfo(selectedConstellation).then((res) => {
        const nameDate = fetchConstellationDate(res.name)
        const avater = fetchConstellationAvater(res.name)
        res.nameDate = nameDate
        res.avater = avater
        this.setData(res)
      })
    },
    clearConstellation() {
      this.triggerEvent('clearConstellation')
    },
  }
})